#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>

const char* filename="log.txt";
int main()
{
  //close(0);
  umask(0);
  int fd=open(filename, O_CREAT | O_RDWR | O_TRUNC /* O_APPEND*/ ,0666);
  if(fd < 0)
  {
    perror("open");
    return 1;
  }
  const char* data="hello\n";
  write(fd,data,strlen(data));
  printf("fd:%d\n",fd);
  close(fd);
  return 0;
}
